﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Soapi.Domain;

namespace Soapi.Notify2
{
    /// <summary>
    /// Interaction logic for QuestionsListView.xaml
    /// </summary>
    public partial class QuestionsListView : UserControl
    {

        public QuestionsListView()
        {
            InitializeComponent();

        }

        private void QuestionListBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete || e.Key == Key.Back)
            {
                lock (QuestionListBox)
                {
                    var toRemove = new List<Question>();
                    for (int i = 0; i < QuestionListBox.SelectedItems.Count; i++)
                    {
                        Question item = (Question)QuestionListBox.SelectedItems[i];
                        toRemove.Add(item);
                    }
                    toRemove.ForEach(q => ((QuestionsCollection)QuestionListBox.ItemsSource).Remove(q));
                }
            }


        }
    }
}
